Skip to content

Conversation

vigna
Copy link

@vigna vigna commented Mar 28, 2025

No description provided.

Comment on lines +259 to +274
//! ## Using the Logger as a Timer
//!
//! `env_logger` can also be used as a timer by moving an initial
//! timestamp into the closure defining a custom format:
//!
//! ```
//! use std::io::Write;
//!
//! let start = std::time::Instant::now();
//! env_logger::builder()
//! .format(move |buf, record| {
//! writeln!(buf, "{} ({}): {}", record.level(), start.elapsed().as_millis(), record.args())
//! })
//! .init();
//! ```
//!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was assuming this would be created as another example in examples/. The advantage of this is its easier to interactively play with to see the results.

If its being added to the docs, putting it on Builder::format might be a better approach.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So sorry to disappoint your expectations 😆.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants